package com.grad.webstudy.service.impl;

import com.grad.webstudy.dao.RoleAuthDao;
import com.grad.webstudy.model.RoleAuth;
import com.grad.webstudy.service.RoleAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description:
 * @Author: zjf
 * @Date: 2020/1/20 14:52.
 */
@Service
@Transactional
public class RoleAuthServiceImpl implements RoleAuthService {

    @Autowired
    private RoleAuthDao roleAuthDao;

    @Override
    public List<String> queryAuthIdsByUserId(int userId) {
        return roleAuthDao.queryAuthIdsByUserId(userId);
    }

    @Override
    public RoleAuth queryRoleAuth(int roleId) {
        return roleAuthDao.queryRoleAuth(roleId);
    }

    @Override
    public boolean addRoleAuth(int roleId, String authIds) {
        return roleAuthDao.insert(new RoleAuth(roleId,authIds))>0;
    }

    @Override
    public boolean updateRoleAuth(int roleId, String authIds) {
        return roleAuthDao.updateRoleAuth(roleId,authIds)>0;
    }

    @Override
    public boolean deleteRoleAuth(List<String> roleIds) {
        return roleIds.size()==roleAuthDao.deleteRoleAuth(roleIds);
    }
}
